const fileTypeMapping = new Map([
    ['md', 'markdown'],
    ['doc', 'word'],
    ['docx', 'word'],
    ['html', 'web'],
    ['xls', 'excel'],
]);

const input = [
    'js-this.md',
    'vue.docx',
    'js-class.md',
    'react.xixi.doc',
    'mp.xls',
    'fe06.xls',
    'fe06.heihei.xls',
    'index.html',
];

const output = {
    word: 2,
    markdown: 2,
    excel: 3,
    web: 1,
};

function getFileCount(input) {
    return input.reduce((prev, current) => {
        const suffix = current.split('.').pop(); // 'md'
        const fileType = fileTypeMapping.get(suffix); // 'markdown'
        if (!prev[fileType]) {
            prev[fileType] = 1;
        } else {
            prev[fileType]++;
        }
        return prev;
    }, {});
}
